< previous page page_257 next page >

Page 257
In other animations, the distortion caused by endpoint interpolation can be very noticeable. The file Square.twe describes two frames showing the same square rotated by 90 degrees. Run TweenEnd and load this file. Create 10 tweens between the key frames, and run the animation reversing at 20 frames per second. As you watch the animation, you can see the distorting effects of endpoint interpolation. As the square rotates back and forth, it shrinks and grows noticeably.
One way to reduce these distortions is to create more key frames. By increasing the number of key frames, you reduce the amount of change between them so the tweens cannot distort the image as much. Of course, this requires that you create more key frames, the very thing that tweening was invented to prevent.
The file Square2.twe shows the same animation as Square.twe, with one extra key frame in the middle. Load this file, and create five tweens between key frames. When you run the animation, you will still see some distortion but not as much as before.
Script Interpolation
If your animation is controlled by a script, you can create tweens by interpolating the script parameters. For example, the Robot program described earlier in this chapter uses several control variables to determine the robot's position. To create tweens, you can interpolate the values of these variables between key frames.
Because the animation is controlled by script variables, tweening does not introduce distortions. No matter what parameters the interpolations create, the program can create the corresponding scene without distortion.
Example program TweenRob creates tweens for simple robot scripts by interpolating script variables. Select the File menu's Load command to load the file Jacks.rob. This file defines seven frames that make the robot do jumping jacks. Run the file as a reversing animation at 20 frames per second, and you will see relatively smooth motion.
Now load the file Jackstw.rob. This file defines only three jumping jacks frames. Enter 10 for the number of tweens to create and press the Tween button. Then run the file as a reversing animation at 60 frames per second. You should run this animation at about three times the speed of the other because it uses about three times as many frames to define the same amount of action. This gives you roughly the same number of jumps per second. The file Jackstw.rob takes less room to store than Jacks.rob because it defines only three frames instead of seven. You can still use it to produce smooth animation by creating tweens.
It is interesting to see what happens if you remove the middle frame from the file Jackstw.rob. Load the file, select the second frame, and invoke the Frames menu's Delete command. Then create 10 tweens between the two remaining frames and run the animation. You will see a very different result than you saw before.
During the parameter interpolations, the program ''takes the shortest path" from one parameter value to the next. After you delete the middle key frame, the shortest path between the remaining frames looks more like a toe touch than a jumping jack. When

 
< previous page page_257 next page >